<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // function sayHi() {
    //   console.log(name) // undefined
    //   console.log(age); // Uncaught ReferenceError: Cannot access 'age' before initialization
    //   var name = 'wujf'
    //   let age = 12;
    // }
    // sayHi();

    // for (var i = 0; i < 3; i++) {
    //   setTimeout(() => console.log(i), 1) // 333
    // }

    // for (let i = 0; i < 3; i++) {
    //   setTimeout(() => console.log(i), 1) // 012
    // }
    var name = '张三'
    // const obj = {
    //   name:'wujf',
    //   sayName(){
    //     return this.name;
    //   },
    //   getName:() => this.name
    // }
    // console.log(obj.sayName()) // wujf
    // console.log(obj.getName()) // 张三

    // 箭头函数不能使用call，bind等
    function myCall() {
      console.log(this)
    }
    const fn = ()=> console.log(this);
    myCall(); // window
    myCall.call({}); // {}
    fn.call({}); // window
    fn(); // window
  </script>
</body>
</html>